package com.changpay.zywy.adapter

import android.content.Context
import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ruffian.library.widget.RTextView
import com.changpay.zywy.R
import com.changpay.zywy.bean.ChannelTrading
import org.jetbrains.anko.textColor

/**
 * Created by chenxz on 2018/4/22.
 */
class TradingTrandAdapter(private val context: Context?, datas: MutableList<ChannelTrading.ChannelTradingBean>) :
    BaseQuickAdapter<ChannelTrading.ChannelTradingBean, BaseViewHolder>(R.layout.item_month_trand, datas) {

    override fun convert(helper: BaseViewHolder?, item: ChannelTrading.ChannelTradingBean?) {
        item ?: return
        helper ?: return
        val progress = helper.getView<RTextView>(R.id.tv_money)
        progress.text = item.totalAmount.toString()
        helper.setText(R.id.tv_name,item.member_name)
        if (item.totalAmount == 0) {
            progress.helper.borderColorNormal = Color.parseColor("#EBE4D7")
            progress.textColor = Color.parseColor("#EBE4D7")
        } else {
            val position = getParentPosition(item)
            if (position.rem(4) == 0 and 1) {
                progress.helper.borderColorNormal = Color.parseColor("#7ECEF4")
                progress.textColor = Color.parseColor("#7ECEF4")
            } else {
                progress.helper.borderColorNormal = Color.parseColor("#FDC67E")
                progress.textColor = Color.parseColor("#FDC67E")
            }
        }
    }

}
